package my.sample.db.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class InsertIfNot {

	final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
	Connection connection = null;
	
	public InsertIfNot() {
		try {
			Class.forName(JDBC_DRIVER);
			connection = DriverManager.getConnection("jdbc:mysql://119.226.225.240:3306/beaserv", "root", "infra@vm");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	
	public void exec() {
		Statement statement = null;
		ResultSet result = null;
		try {
			statement = this.connection.createStatement();
			result = statement.executeQuery("select device_backup from backup_analyzer_status where backup_date='2014-08-08'");
			while( result.next()) {
				System.out.println(result.getInt("analyze_id"));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		
	}


	public static void main(String[] args) {
		
		InsertIfNot insert = new InsertIfNot();
		insert.exec();
		
	}

}
